package com.example.shengyin.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

//@Configuration
//@EnableSwagger2
public class LHXConfig implements WebMvcConfigurer {
    @Autowired
    private RedisTemplate redisTemplate;

    @Override//不需要@bean注解
    public void addInterceptors(InterceptorRegistry registry) {
//        TimeInterceptor t=new TimeInterceptor();//"/students.html","/js/**",
//        registry.addInterceptor(timeInterceptor).excludePathPatterns("/swagger-ui/**","/**.css","**/static/**","/**.html","/**.jpg","/**.png","/getCode","/admin/login").addPathPatterns("/**");

        //设置redis
        RoleInterceptor role=new RoleInterceptor();//"/students.html","/js/**",
        role.setRedisTemplate(redisTemplate);
        registry.addInterceptor(role).excludePathPatterns("**example**","/swagger-resources","/swagger-resources/**","/webjars/*","/v3/**",
                "/swagger-ui/**","/**.css","/**/**.js","/Layui/**","/**.jpg","/**.png","/admin/login/**","/**/user/reg","/getCode"
                ,"/front/**","/shengyin/front/**","/shengyin/Layui/**").addPathPatterns("/**");

    }
}